const getSvg = (name: string): string => {
    if (typeof name === 'undefined') return 'error.png';
    const path = `/src/assets/icons/${name}.svg`;
    const modules = import.meta.glob('/src/assets/icons/*');
    return modules[path]?.name;
}

const getImage = (name: string): string => {
    if (typeof name === 'undefined') return 'error.png';
    let path: string = `/src/assets/images/${name}.png`;
    let modules = import.meta.glob('/src/assets/images/*');
    // 如果没找到png图片，则去寻找jpg图片
    if (modules[path]) {
        return modules[path]?.name;
    } else {
        path = `/src/assets/img/${name}.jpg`;
        modules = import.meta.glob('/src/assets/images/*');
        if (modules[path]) {
            return modules[path]?.name;
        } else
            return 'error.png';
    }
}

const getMd = (name: string): string => {
    return `/src/assets/md/${name}.md`;
}

export { getSvg, getImage, getMd }
